package com.tjetc.service.impl;

import com.tjetc.common.Resp;
import com.tjetc.dao.AppointmentMapper;
import com.tjetc.dao.RoomMapper;
import com.tjetc.dao.UserMapper;
import com.tjetc.entity.Appointment;
import com.tjetc.entity.Room;
import com.tjetc.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class RoomServiceImpl implements RoomService {
    @Autowired
    private RoomMapper roomMapper;
    @Autowired
    private UserMapper userMapper;

    @Override
    public Resp getAllRoom() {
        List<Integer> roomAllId = roomMapper.getAllRoomId();
        List<Map<String,String>> mapList = new ArrayList<>();
        LocalDate date = LocalDate.now();
        LocalDate newDate = date.plusDays(1);
        String time = newDate + " 08:00:00";
        roomAllId.forEach(id-> mapList.add(roomMapper.getRoomByIdAndTime(id,time)));
        return Resp.ok().data("roomList",mapList);
    }
}
